package com.wlscale.roadsystem.wiget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.wlscale.roadsystem.R;


public class CarTypeTextView extends LinearLayout {
    /**
     * 上下文
     */
    private Context mContext;
    /**
     *
     */
    private LinearLayout containerView;
    /**
     * 车类型
     */
    private int carType = 0;

    public CarTypeTextView(Context context) {
        super(context);
        init(context);
    }

    public CarTypeTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public CarTypeTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(final Context mContext) {
        this.mContext = mContext;
        containerView = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.car_type_text_view, null);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        this.addView(containerView, params);
        containerView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                CarTypePopPopupWindow carTypePopPopupWindow = new CarTypePopPopupWindow(mContext, new CarTypePopPopupWindow.ReslutOnClickLister() {
                });
                carTypePopPopupWindow.show(CarTypeTextView.this);
            }
        });
    }

    /**
     * 获取车的类型
     *
     * @return
     */
    public int getCarType() {
        return carType;
    }


}
